#ifndef __TASK_ETHERNET_H
#define __TASK_ETHERNET_H	

#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "string.h"
#include "delay.h"
#include "time.h"
#include "sys.h"
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

#include "gxhtc3.h"
#include "esp8266.h"
#include "task_net.h"
#include "currency.h"
#include "flash.h"
#include "HLW8112.h"
#include "gps.h"
#include "alarm.h"

/*
 * Derived generic types.
 */
typedef volatile int8_t     vint8_t;        /**< Volatile signed 8 bits.    */
typedef volatile uint8_t    vuint8_t;       /**< Volatile unsigned 8 bits.  */
typedef volatile int16_t    vint16_t;       /**< Volatile signed 16 bits.   */
typedef volatile uint16_t   vuint16_t;      /**< Volatile unsigned 16 bits. */
typedef volatile int32_t    vint32_t;       /**< Volatile signed 32 bits.   */
typedef volatile uint32_t   vuint32_t;      /**< Volatile unsigned 32 bits. */
typedef volatile uint64_t   vuint64_t;      /**< Volatile unsigned 64 bits. */

typedef uint8_t			  u_char;		/**< 8-bit value */
typedef uint8_t 			socket_t;
typedef uint16_t			u_short;	/**< 16-bit value */
typedef uint16_t			u_int;		/**< 16-bit value */
typedef uint32_t			u_long;		/**< 32-bit value */


#define FORMAT_TYPE_NM  	0xF
#define FORMAT_TYPE_LE  	0xFF

#define FORMAT_TYPE_JASON  	0xEC

#define false    0
#define true     1
	
#define HW_VERSION 			"WL003"
#define FW_VERSION 			"TY012"
#define WSBUF_SIZE      	512

#define INIT        0

//#define LANRST PBout(1)
#define LANRST PCout(6)

#define UDP              0
#define TCP              1
#define DHCP_IP          0
#define STATIC_IP        1
#define IPV4_TYPE        1


#define NM_MAX_DATA_LEN    (255)


enum _LanStatus{
	LANSTATUS_INIT = 0,
	LANSTATUS_POWER_OFF,
	LANSTATUS_POWER_ON,
	LANSTATUS_HARD_RESET,
	LANSTATUS_SOFT_READY,
	LANSTATUS_CHECK_PHY,
	LANSTATUS_CONFIG_MAC,
	LANSTATUS_CONFIG_NETWORK,
	LANSTATUS_802D1X_AUTH,	// 802.1X
	LANSTATUS_CREATE_SOCKET,
	LANSTATUS_CONNECT,
	LANSTATUS_LOOP,
	LANSTATUS_DISCONN,	
	LANSTATUS_CLOSE_SOCKET,
	LANSTATUS_EXIT,
	LANSTATUS_ERROR,
	LANSTATUS_LEISURE,
};


extern uint8_t NET_DHCP_STATE[];

void nm_Heartbeat_packetData(void);
void ethernet_task_create(u8 prio);

static uint8_t nm_clear_alarm_Data(uint8_t data[], uint16_t len);
char *InterceptMiddleString (char *g_str, char *str, char *left_str, char *right_str);


void reboot(void);

#endif
